﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Uco.Models;
using System.Diagnostics;
using System.Net.Mail;
using System.Configuration;
using System.Text;
using System.Reflection;
using System.Globalization;
using System.Web.Configuration;
using System.Dynamic;
using System.Web.Mvc;
using System.Xml;
using Telerik.Web.Mvc.UI;
using System.IO;

namespace Uco.Infrastructure
{
    public static partial class CleanCache
    {
        #region Other

        public static void RestartApplication()
        {
            HttpRuntime.Close();
        }

        public static void CleanCacheAfterPageEdit()
        {
            CleanMenuCache();
            CleanOutputCache();
            SF.RefreshMenuRepository();
        }

        public static void CleanImageCache()
        {
            string sourceDir = System.Web.HttpContext.Current.Server.MapPath("~/App_Data/cache/images");
            foreach (string item in Directory.GetFiles(sourceDir, "*.*"))
            {
                System.IO.File.Delete(item);
            }
        }

        public static void CleanSettingsCache()
        {
            SF.CleanSettingsRepository();
        }

        public static void CleanMenuCache()
        {
            SF.CleanMenuRepository();
            SF.RefreshMenuRepository();
        }


        public static void CleanOutputCache()
        {
            HttpContext.Current.Cache.Remove("CleanCacheGuid");
        }


        #endregion

    }

}